package com.kk.iterator;

import java.util.Iterator;
import java.util.List;

public class OutPutImpl {

    //学院集合
    private List<College> collegeList;

    public OutPutImpl(List<College> collegeList) {
        this.collegeList = collegeList;
    }

    /**
     * 遍历各学院
     */
    public void printCollege() {
        Iterator<College> iterator = collegeList.iterator();
        while (iterator.hasNext()) {
            College college = iterator.next();

            System.out.println("===============学院：");
            System.out.println(college.getName());
            printDepartment(college.createIerator());
        }
    }

    /**
     * 遍历各学院下的各专业
     *
     * @param iterator
     */
    private void printDepartment(Iterator iterator) {
        System.out.println("===============专业：");
        while (iterator.hasNext()) {
            Department department = (Department) iterator.next();


            System.out.println(department.getName());
        }
        System.out.println("============================");
    }

}
